import os

from .json_helper import json_helper
from .dataset_tools import dataset_tools

class sentinel12_tools(dataset_tools):
    key = "Sentinel12"

    def get_wkt(self, sample) -> str:
        """
        image name to wkt
        
        Param
        -----
        sample the identifier of sample, e.g. path or point
        """
        sample = os.path.splitext(sample)[0]
        sample = os.path.basename(sample)
        s = sample.split("_")
        roi = "_".join([s[0], s[1]])
        region = s[3]
        patch = s[4]
        
        return str((roi, region, patch))

if __name__ == "__main__":
    import numpy as np
    import cv2 as cv

    dt = sentinel12_tools("", "E:/workspace/SOMatch/tmp/json/sen12_tt_harris/pt_s100.json")
    print(f"{len(dt)} pairs loaded")
    lt = dt.get_pair_list()
    img0 = dt.get_patch(lt[10][0])
    img1 = dt.get_patch(lt[10][1])
    img = np.concatenate((img0, img1), axis=1)
    cv.imshow("", img)
    cv.waitKey(100)